<?php
/**
 * Update user,group and mode for current object. Used some post data.
 *
 * PHP versions 5
 *
 * Copyright (C)
 * This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation. Either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Without even the implied warranty
 * of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program. Ff not, write to the Free Software
 * Fundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 * Copyright (C) 2006-2007
 *
 * @author Bastian Schröder <bs@chemanet.de>
 * @version 2008-04-19
 * @package railbrowser
 */

function ajax_call( $ajaxBridge ) {
	global $rail, $object;

	// try to reset rights and mode
	try{
		// set mode
		$object->set_mode(
			$_POST['rights_user_mode'].$_POST['rights_group_mode'].$_POST['right_other'],
			isset($_POST['rights_rekursiv']) && $_POST['rights_rekursiv']=='on' ? true : false
		);


		$user = rail_factory::get_object( $rail, $_POST['rights_user'] );
		$group = rail_factory::get_object( $rail, $_POST['rights_group'] );
		// set user and group
		if( $rail->get_user()->get_name() == 'root' )
			$object->set_user( $user, $group,
							  isset($_POST['rights_rekursiv']) && $_POST['rights_rekursiv']=='on' ? true : false
			);
		else
			$object->set_group( $group,
							    isset($_POST['rights_rekursiv']) && $_POST['rights_rekursiv']=='on' ? true : false
			);
	}
	catch( Exception $e ){ $ajaxBridge->register_exception( $e, 3 ); }
}

?>